/***********************************************************************
 * Module:  StealRobVehicleController.java
 * Author:  Administrator
 * Purpose: Defines the Class StealRobVehicleController
 ***********************************************************************/

package ishitong.vehicleManagement.controller;

import ishitong.vehicleManagement.model.StealRobVehicle;
import ishitong.common.SysCodeType;
import ishitong.common.model.SysCode;
import ishitong.commons.pagination.Pagination;
import ishitong.vehicleManagement.model.StealRobVehicleQuery;
import ishitong.vehicleManagement.service.biz.StealRobVehicleService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.ishitong.platform.common.page.Page;

/** @pdOid 9ffadc68-3a33-4ac2-9465-9335800c3b0f */
@Controller
public class StealRobVehicleController extends ishitong.common.controller.ActionController {
   /** @pdOid faba109f-6720-42ec-a214-1493f77e2349 */
   private static final String STE_ROB_VEH_SCH = "vehicleManagement/stealRobVehicle/stealRobVehicleSearch";
   /** @pdOid 2235c3b0-4d2c-49ff-9268-1c7fc6334401 */
   private static final String STE_ROB_VEH_SCH_LST = "vehicleManagement/stealRobVehicle/stealRobVehicleSearchList";
   /** @pdOid 06c34a81-6eba-4f68-a0f7-ce2d04e9f854 */
   private static final String STE_ROB_VEH_EDT = "vehicleManagement/stealRobVehicle/stealRobVehicleEdit";
   /** @pdOid 8f48be99-50c9-4e5c-91b6-2948b5f4fccc */
   private static final String STE_ROB_VEH_VIW = "vehicleManagement/stealRobVehicle/stealRobVehicleView";
   /** @pdOid f179d14a-f1f5-4c20-8264-a50c49c9e51f */
   @Autowired
   private StealRobVehicleService stealRobVehicleService;
   
   /** @param request
    * @exception Exception
    * @pdOid 9dfe1f4c-6ce0-4acc-a76d-1a12bb78c9e5 */
   @RequestMapping(value = "/showStealRobVehicleSearch.do")
   public ModelAndView handleShowStealRobVehicleSearch(HttpServletRequest request) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND); 
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   		// 使用性质
   		List<SysCode> lstUseNature = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.USE_NATURE);
   		model.put("lstUseNature", lstUseNature);
   
   		// 车辆分类
   		List<SysCode> lstVehicleSort = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_SORT);
   		model.put("lstVehicleSort", lstVehicleSort);
   
   		// 车辆类型
   		List<SysCode> lstVehicleType = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   		return new ModelAndView(STE_ROB_VEH_SCH,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param stealRobVehicleQuery 
    * @param pagination
    * @pdOid b40a1bf7-e45e-498d-bf58-dd60a07ac4ed */
   @RequestMapping(value = "/ajaxStealRobVehicleSearchList.do",method = RequestMethod.POST)
   public ModelAndView handleAjaxFindStealRobVehicleSelectList(HttpServletRequest request, StealRobVehicleQuery stealRobVehicleQuery, Pagination pagination) {
   	try {
   		Map<String, Object> model = new HashMap<>();
   		Page<StealRobVehicle> page = this.stealRobVehicleService.findPage(stealRobVehicleQuery, pagination.getPageSize(), pagination.getCurrentPage());
   		model.put("page", page);
   		return new ModelAndView(STE_ROB_VEH_SCH_LST,model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param stealRobVehicleId
    * @exception Exception
    * @pdOid bd179769-7c58-40fb-b500-ca0d31f2e687 */
   @RequestMapping(value = "/ajaxShowStealRobVehicleEdit.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowStealRobVehicleEdit(HttpServletRequest request, String stealRobVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   
   		// 号牌种类
   		List<SysCode> lstLicencePlateKind = spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_KIND);
   		model.put("lstLicencePlateKind", lstLicencePlateKind);
   		// 号牌颜色
   		List<SysCode> lstPlateColor =  spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.PLATE_COLOR);
   		model.put("lstPlateColor", lstPlateColor);
   		// 车辆类型
   		List<SysCode> lstVehicleType =  spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_TYPE);
   		model.put("lstVehicleType", lstVehicleType);
   		// 车身颜色
   		List<SysCode> lstVehicleColor =  spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_COLOR);
   		model.put("lstVehicleColor", lstVehicleColor);
   		// 使用性质
   		List<SysCode> lstUseNature =  spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.USE_NATURE);
   		model.put("lstUseNature", lstUseNature);
   		// 车辆分类
   		List<SysCode> lstVehicleClassification =  spiSysCodeService.getSysCodeListByTypeCode(SysCodeType.VEHICLE_SORT);
   		model.put("lstVehicleClassification", lstVehicleClassification);
   
   		if(!StringUtils.isEmpty(stealRobVehicleId)){
   			StealRobVehicle stealRobVehicle=stealRobVehicleService.findById(stealRobVehicleId);
   			model.put("stealRobVehicle",stealRobVehicle);
   		}
   		return new ModelAndView(STE_ROB_VEH_EDT, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param stealRobVehicle 
    * @param response
    * @exception Exception
    * @pdOid d082d487-23a2-41ec-9f42-6fb1b949d563 */
   @RequestMapping(value = "/ajaxSaveStealRobVehicle.do", method = RequestMethod.POST)
   public void handleAjaxSaveStealRobVehicle(HttpServletRequest request, StealRobVehicle stealRobVehicle, HttpServletResponse response) throws Exception {
   	try {
   		stealRobVehicleService.save(stealRobVehicle);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }
   
   /** @param request 
    * @param stealRobVehicleId
    * @exception Exception
    * @pdOid e6a16325-ea67-4f9d-8f9d-dabd21b05474 */
   @RequestMapping(value = "/ajaxShowStealRobVehicleView.do", method = RequestMethod.POST)
   public ModelAndView handleAjaxShowStealRobVehicleView(HttpServletRequest request, String stealRobVehicleId) throws Exception {
   	try {
   		Map<String, Object> model = new HashMap<String, Object>();
   		if(!StringUtils.isEmpty(stealRobVehicleId)){
   			StealRobVehicle stealRobVehicle = stealRobVehicleService.findById(stealRobVehicleId);
   			model.put("stealRobVehicle", stealRobVehicle);
   		}
   		return new ModelAndView(STE_ROB_VEH_VIW, model);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   	return null;
   }
   
   /** @param request 
    * @param stealRobVehicleIds 
    * @param response
    * @exception Exception
    * @pdOid aea17b53-63e7-487f-a428-3cf26d143d3f */
   @RequestMapping(value = "/ajaxDeleteStealRobVehicleByIds.do", method = RequestMethod.POST)
   public void handleAjaxDeleteStealRobVehicleByIds(HttpServletRequest request, String stealRobVehicleIds, HttpServletResponse response) throws Exception {
   	try {
   		stealRobVehicleService.delete(stealRobVehicleIds);
   	} catch (Exception e) {
   		e.printStackTrace();
   	}
   }

}